package com.example.demo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.dto.Gkpaperorder.GkpaperorderQueryRequest;
import com.example.demo.entity.Gkpaperorder;
import com.example.demo.service.GkpaperorderService;
import com.example.demo.dao.GkpaperorderMapper;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author darling
* @description 针对表【gkpaperorder】的数据库操作Service实现
* @createDate 2025-04-30 09:28:47
*/
@Service
public class GkpaperorderServiceImpl extends ServiceImpl<GkpaperorderMapper, Gkpaperorder>
    implements GkpaperorderService{

    @Override
    public QueryWrapper<Gkpaperorder> getQueryWrapper(GkpaperorderQueryRequest gkpaperorderQueryRequest) {
        QueryWrapper<Gkpaperorder> queryWrapper = new QueryWrapper<>();

        Integer id = gkpaperorderQueryRequest.getId();
        String number = gkpaperorderQueryRequest.getNumber();
        String outTradeNo = gkpaperorderQueryRequest.getOutTradeNo();
        Integer gkpaperid = gkpaperorderQueryRequest.getGkpaperid();
        Integer userid = gkpaperorderQueryRequest.getUserid();
        String username = gkpaperorderQueryRequest.getUsername();
        String gkpapername = gkpaperorderQueryRequest.getGkpapername();
        Integer price = gkpaperorderQueryRequest.getPrice();
        Date createtime = gkpaperorderQueryRequest.getCreatetime();
        Integer type = gkpaperorderQueryRequest.getType();
        String state = gkpaperorderQueryRequest.getState();
        String sortField = gkpaperorderQueryRequest.getSortField();
        String sortOrder = gkpaperorderQueryRequest.getSortOrder();
        //精确查询
        queryWrapper.eq(ObjectUtils.isNotEmpty(id), "id", id);
        queryWrapper.eq(ObjectUtils.isNotEmpty(number), "number", number);
        queryWrapper.eq(ObjectUtils.isNotEmpty(outTradeNo), "outTradeNo", outTradeNo);
        queryWrapper.eq(ObjectUtils.isNotEmpty(gkpaperid), "gkpaperid", gkpaperid);
        queryWrapper.eq(ObjectUtils.isNotEmpty(userid), "userid", userid);
        queryWrapper.eq(ObjectUtils.isNotEmpty(price), "price", price);
        queryWrapper.eq(ObjectUtils.isNotEmpty(createtime), "createtime", createtime);
        queryWrapper.eq(ObjectUtils.isNotEmpty(type), "type", type);
        queryWrapper.eq(ObjectUtils.isNotEmpty(state), "state", state);
        //模糊查询
        queryWrapper.like(ObjectUtils.isNotEmpty(username), "username", username);
        queryWrapper.like(ObjectUtils.isNotEmpty(gkpapername), "gkpapername", gkpapername);

        //排序规则
        queryWrapper.orderBy(ObjectUtils.isNotEmpty(sortField), sortOrder.equals("ascend"), sortField);

        return queryWrapper;
    }
}




